<table>
<tr><td>Date</td><td>Time</td><td>Student</td><td>Subject</td></tr>
<?php
	$userid = $this->session->userdata("userid");
	$constraints = array(
	                     "teacherid" => $userid,
	                     "adminstatus" => "approved"
	                     );
	
	$query = $this->db->get_where("schedule", $constraints);
	
	foreach($query->result() as $row){
		echo "<tr>";
		$student_name = $this->db->get_where("students", array("userid" => $row->studentid));
		$name = "";
		
		foreach($student_name->result() as $sn){
			$name = $sn->lastname . ", " . $sn->firstname;
		}
		
		$subject_name = $this->db->get_where("subjects", array("subjectid" => $row->subjectid));
		$sname = "";
		
		foreach($subject_name->result() as $subname){
			$sname = $subname->subjectname;
		}
		
		echo "<td>" . $row->date . "</td><td>" . $row->time . "</td><td>" . $name . "</td><td>" . $sname . "</td>";
		echo "</tr>";
	}
?>
</table>
